﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NetSnmpAgentBasedTest.cs" company="Data Ductus Malmö">
//   (c) 2010 - 2012 Data Ductus Malmö AB
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace DataDuctus.Snmp.Persistor.Core.Tests
{
  using DataDuctus.Snmp.EmbeddableNetSnmp;

  using Microsoft.VisualStudio.TestTools.UnitTesting;

  /// <summary>
  /// Base type for all tests that needs a net-snmp agent running.
  /// </summary>
  [TestClass]
  public abstract class NetSnmpAgentBasedTest
  {
    /// <summary>
    /// Gets or sets TestContext.
    /// </summary>
    public TestContext TestContext { get; set; }

    /// <summary>
    /// Gets the agent.
    /// </summary>
    public EmbeddableSnmpAgent Agent { get; private set; }

    #region Public Methods

    /// <summary>
    /// The cleanup test.
    /// </summary>
    [TestCleanup]
    public void CleanupTest()
    {
      EmbeddableSnmpAgent agent = this.Agent;
      this.Agent = null;

      if (null != agent)
      {
        agent.Dispose();
      }
    }

    /// <summary>
    /// The init test.
    /// </summary>
    [TestInitialize]
    public void InitTest()
    {
      this.Agent = new EmbeddableSnmpAgent();
     
      this.Agent.Open();
    }

    #endregion
  }
}
